package org.jeecg.modules.online.cgform.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;

import java.lang.invoke.SerializedLambda;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.dto.DataLogDTO;
import org.jeecg.common.config.mqtoken.UserTokenContext;
import org.jeecg.common.exception.TuringBootException;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.util.JeecgDataAutorUtils;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.system.vo.SysPermissionDataRuleModel;
import org.jeecg.common.util.SqlInjectionUtil;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.online.auth.p004b.AuthConstants;
import org.jeecg.modules.online.auth.service.IOnlAuthDataService;
import org.jeecg.modules.online.auth.service.IOnlAuthPageService;
import org.jeecg.modules.online.cgform.consts.ExtendJsonKey;
import org.jeecg.modules.online.cgform.consts.OnlineConst;
import org.jeecg.modules.online.cgform.entity.OnlCgformField;
import org.jeecg.modules.online.cgform.entity.OnlCgformHead;
import org.jeecg.modules.online.cgform.enums.CgformConstant;
import org.jeecg.modules.online.cgform.mapper.OnlCgformFieldMapper;
import org.jeecg.modules.online.cgform.mapper.OnlCgformHeadMapper;
import org.jeecg.modules.online.cgform.mapper.OnlineMapper;
import org.jeecg.modules.online.cgform.model.OnlQueryModel;
import org.jeecg.modules.online.cgform.model.SqlOrder;
import org.jeecg.modules.online.cgform.model.TreeModel;
import org.jeecg.modules.online.cgform.p007a.LinkDown;
import org.jeecg.modules.online.cgform.service.IOnlCgformFieldService;
import org.jeecg.modules.online.cgform.utils.CgformUtil;
import org.jeecg.modules.online.cgreport.constant.CgReportConstant;
import org.jeecg.modules.online.cgreport.service.IOnlCgreportAPIService;
import org.jeecg.modules.online.cgreport.util.CgReportSqlUtil;
import org.jeecg.modules.online.config.p020b.DataBaseConfig;
import org.jeecg.modules.online.config.p022d.DbTableUtil;
import org.jeecg.modules.online.p002a.ConditionHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

@Service("onlCgformFieldServiceImpl")
/* renamed from: org.jeecg.modules.online.cgform.service.a.c */
/* loaded from: hibernate-re-3.7.1-RC.jar:org/jeecg/modules/online/cgform/service/a/c.class */
public class OnlCgformFieldServiceImpl extends ServiceImpl<OnlCgformFieldMapper, OnlCgformField> implements IOnlCgformFieldService {
    @Autowired
    IOnlCgreportAPIService onlCgreportAPIService;
    @Autowired
    private OnlCgformFieldMapper onlCgformFieldMapper;
    @Autowired
    private OnlCgformHeadMapper cgformHeadMapper;
    @Autowired
    private IOnlAuthDataService onlAuthDataService;
    @Autowired
    private IOnlAuthPageService onlAuthPageService;
    @Autowired
    @Lazy
    private ISysBaseAPI sysBaseAPI;
    @Autowired
    private OnlineMapper onlineMapper;

    /* renamed from: c */
    private static final String f454c = "0";

    /* renamed from: b */
    private static final Logger f453b = LoggerFactory.getLogger(OnlCgformFieldServiceImpl.class);

    /* renamed from: a */
    public static ExecutorService f455a = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60, TimeUnit.SECONDS, new SynchronousQueue());

    /* renamed from: a */
    private static /* synthetic */ Object m238a(SerializedLambda serializedLambda) {
        String implMethodName = serializedLambda.getImplMethodName();
        String implClass = serializedLambda.getImplClass();
        if(implClass.equals("org/jeecg/modules/online/cgform/entity/OnlCgformHead")) {
        }
        switch (implMethodName) {
            case "getTableName":
            	 return "";
            case "getTableType":
                break;
            case "getFieldShowType":
                break;
            case "getIsShowForm":
                break;
            case "getIsShowList":
                break;
            case "getDbIsPersist":
                break;
            case "getIsQuery":
                break;
            case "getOrderNum":
                break;
            case "getMainTable":
                break;
            case "getSubTableStr":
                break;
            case "getId":
                break;
            case "getCgformHeadId":
                break;
            case "getTableTxt":
                break;
            case "getDbFieldName":
                break;
            case "getRelationType":
                break;
        }
		return "";
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public Map<String, Object> queryAutolistPage(OnlCgformHead head, Map<String, Object> params, List<String> needList) {
        OnlQueryModel queryInfo = getQueryInfo(head, params, needList);
        String sql = queryInfo.getSql();
        Map<String, Object> params2 = queryInfo.getParams();
        List<OnlCgformField> fieldList = queryInfo.getFieldList();
        HashMap hashMap = new HashMap(5);
        Integer valueOf = Integer.valueOf(params.get("pageSize") == null ? 10 : Integer.parseInt(params.get("pageSize").toString()));
        if (valueOf.intValue() == -521) {
            List<Map<String, Object>> selectByCondition = this.onlineMapper.selectByCondition(sql, params2);
            if (selectByCondition == null || selectByCondition.size() == 0) {
                hashMap.put("total", 0);
                hashMap.put("fieldList", fieldList);
            } else {
                hashMap.put("total", Integer.valueOf(selectByCondition.size()));
                hashMap.put("fieldList", fieldList);
                hashMap.put("records", CgformUtil.m322d(selectByCondition));
            }
        } else {
            IPage<Map<String, Object>> selectPageByCondition = this.onlineMapper.selectPageByCondition(new Page<>(Integer.valueOf(params.get("pageNo") == null ? 1 : Integer.parseInt(params.get("pageNo").toString())).intValue(), valueOf.intValue()), sql, params2);
            hashMap.put("total", Long.valueOf(selectPageByCondition.getTotal()));
            List<Map<String, Object>> m322d = CgformUtil.m322d(selectPageByCondition.getRecords());
            handleLinkTableDictData(head.getId(), m322d);
            m224a(head, m322d);
            hashMap.put("records", m322d);
        }
        return hashMap;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public Map<String, Object> queryAutoTreeNoPage(String tbname, String headId, Map<String, Object> params, List<String> needList, String pidField) {
        Map hashMap = new HashMap(5);
        LambdaQueryWrapper<OnlCgformField>  lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, headId);
        lambdaQueryWrapper.orderByAsc(OnlCgformField::getOrderNum);
        List<OnlCgformField> fieldList = list(lambdaQueryWrapper);
        List<OnlCgformField> queryAvailableFields = queryAvailableFields(headId, tbname, true, fieldList, needList);
        StringBuffer stringBuffer = new StringBuffer();
        CgformUtil.m371a(tbname, queryAvailableFields, stringBuffer);
        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        List<SysPermissionDataRuleModel> queryUserOnlineAuthData = this.onlAuthDataService.queryUserOnlineAuthData(loginUser.getId(), headId);
        if (queryUserOnlineAuthData != null && queryUserOnlineAuthData.size() > 0) {
            JeecgDataAutorUtils.installUserInfo(this.sysBaseAPI.getCacheUser(loginUser.getUsername()));
        }
        ConditionHandler conditionHandler = new ConditionHandler("t.");
        conditionHandler.setTableName(tbname);
        conditionHandler.setNeedList(needList);
        conditionHandler.setSubTableStr("");
        String m563a = conditionHandler.m563a(CgformUtil.m313g(fieldList), params, queryUserOnlineAuthData);
        Map<String, Object> sqlParams = conditionHandler.getSqlParams();
        if (m563a.trim().length() > 0) {
            stringBuffer.append(" t ").append(CgformUtil.f211i).append(m563a);
        }
        stringBuffer.append(m233a(fieldList, params));
        Integer valueOf = Integer.valueOf(params.get("pageSize") == null ? 10 : Integer.parseInt(params.get("pageSize").toString()));
        if (valueOf.intValue() == -521) {
            List<Map <String, Object>>  selectByCondition = this.onlineMapper.selectByCondition(stringBuffer.toString(), sqlParams);
            if ("true".equals(params.get("hasQuery"))) {
                HashMap hashMap2 = new HashMap();
                ArrayList arrayList = new ArrayList();
                for (Map<String, Object> map : selectByCondition) {
                    String m360a = CgformUtil.m360a(map, pidField);
                    if (m360a != null && !"0".equals(m360a)) {
                        if (!arrayList.contains(m360a)) {
                            Map<String, Object> m245a = m245a(m360a, tbname, headId, needList, pidField);
                            arrayList.add(m360a);
                            if (oConvertUtils.isNotEmpty(m245a)) {
                                Object obj = m245a.containsKey("id") ? m245a.get("id") : m245a.get("ID");
                                if (oConvertUtils.isNotEmpty(obj)) {
                                    hashMap2.put(obj.toString(), m245a);
                                }
                            }
                        }
                    } else {
                        Object obj2 = map.containsKey("id") ? map.get("id") : map.get("ID");
                        if (oConvertUtils.isNotEmpty(obj2)) {
                            hashMap2.put(obj2.toString(), map);
                        }
                    }
                }
                selectByCondition = new ArrayList(hashMap2.values());
            }
            if (selectByCondition == null || selectByCondition.size() == 0) {
                hashMap.put("total", 0);
                hashMap.put("fieldList", queryAvailableFields);
            } else {
                hashMap.put("total", Integer.valueOf(selectByCondition.size()));
                hashMap.put("fieldList", queryAvailableFields);
                hashMap.put("records", CgformUtil.m322d(selectByCondition));
            }
        } else {
            IPage<Map<String, Object>> selectPageByCondition = this.onlineMapper.selectPageByCondition(new Page<>(Integer.valueOf(params.get("pageNo") == null ? 1 : Integer.parseInt(params.get("pageNo").toString())).intValue(), valueOf.intValue()), stringBuffer.toString(), sqlParams);
            hashMap.put("total", Long.valueOf(selectPageByCondition.getTotal()));
            hashMap.put("records", CgformUtil.m322d(selectPageByCondition.getRecords()));
        }
        return hashMap;
    }

    /* renamed from: a */
    private Map<String, Object> m245a(String str, String str2, String str3, List<String> list, String str4) {
        HashMap hashMap = new HashMap(5);
        hashMap.put("id", str);
        LambdaQueryWrapper<OnlCgformField> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, str3);
        lambdaQueryWrapper.orderByAsc(OnlCgformField::getOrderNum);
        List list2 = list(lambdaQueryWrapper);
        List<OnlCgformField> queryAvailableFields = queryAvailableFields(str3, str2, true, list2, list);
        StringBuffer stringBuffer = new StringBuffer();
        CgformUtil.m371a(str2, queryAvailableFields, stringBuffer);
        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        List<SysPermissionDataRuleModel> queryUserOnlineAuthData = this.onlAuthDataService.queryUserOnlineAuthData(loginUser.getId(), str3);
        if (queryUserOnlineAuthData != null && queryUserOnlineAuthData.size() > 0) {
            JeecgDataAutorUtils.installUserInfo(this.sysBaseAPI.getCacheUser(loginUser.getUsername()));
        }
        ConditionHandler conditionHandler = new ConditionHandler("t.");
        conditionHandler.setTableName(str2);
        conditionHandler.setNeedList(list);
        conditionHandler.setSubTableStr("");
        String m563a = conditionHandler.m563a(CgformUtil.m313g(list2), hashMap, queryUserOnlineAuthData);
        Map<String, Object> sqlParams = conditionHandler.getSqlParams();
        stringBuffer.append(" t ").append(CgformUtil.f211i).append(" id = '").append(str).append("' ");
        if (m563a.trim().length() > 0) {
            stringBuffer.append(CgReportSqlUtil.f508b).append(m563a);
        }
        List<Map<String, Object>> selectByCondition = this.onlineMapper.selectByCondition(stringBuffer.toString(), sqlParams);
        if (selectByCondition != null && selectByCondition.size() > 0) {
            Map<String, Object> map = selectByCondition.get(0);
            if (map != null && map.get(str4) != null && !"0".equals(map.get(str4))) {
                return m245a(map.get(str4).toString(), str2, str3, list, str4);
            }
            return map;
        }
        return null;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public void saveFormData(String code, String tbname, JSONObject json, boolean isCrazy) {
        LambdaQueryWrapper<OnlCgformField> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, code);
        List list = list(lambdaQueryWrapper);
        if (isCrazy) {
            Map<String, Object> m330c = CgformUtil.m330c(tbname, list, json);
            addOnlineInsertDataLog(tbname, m330c.get("id").toString());
            ((OnlCgformFieldMapper) this.baseMapper).executeInsertSQL(m330c);
            return;
        }
        Map<String, Object> m372a = CgformUtil.m372a(tbname, list, json);
        addOnlineInsertDataLog(tbname, m372a.get("id").toString());
        ((OnlCgformFieldMapper) this.baseMapper).executeInsertSQL(m372a);
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public void saveTreeFormData(String code, String tbname, JSONObject json, String hasChildField, String pidField) {
        LambdaQueryWrapper<OnlCgformField> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, code);
        List<OnlCgformField> list = list(lambdaQueryWrapper);
        for (OnlCgformField onlCgformField : list) {
            if (hasChildField.equals(onlCgformField.getDbFieldName()) && onlCgformField.getIsShowForm().intValue() != 1) {
                onlCgformField.setIsShowForm(1);
                json.put(hasChildField, "0");
            } else if (pidField.equals(onlCgformField.getDbFieldName()) && oConvertUtils.isEmpty(json.get(pidField))) {
                onlCgformField.setIsShowForm(1);
                json.put(pidField, "0");
            }
        }
        Map<String, Object> m372a = CgformUtil.m372a(tbname, list, json);
        addOnlineInsertDataLog(tbname, m372a.get("id").toString());
        ((OnlCgformFieldMapper) this.baseMapper).executeInsertSQL(m372a);
        if (!"0".equals(json.getString(pidField))) {
            UpdateWrapper<?> updateWrapper = new UpdateWrapper<>();
            JSONObject jSONObject = new JSONObject();
            jSONObject.put(hasChildField, "1");
            updateWrapper.eq("id", json.getString(pidField));
            m255a(tbname, jSONObject, updateWrapper);
        }
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public void saveFormData(List<OnlCgformField> fieldList, String tbname, JSONObject json) {
        this.onlCgformFieldMapper.executeInsertSQL(CgformUtil.m372a(tbname, fieldList, json));
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public void editFormData(String code, String tbname, JSONObject json, boolean isCrazy) {
        LambdaQueryWrapper<OnlCgformField> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, code);
        List list = list(lambdaQueryWrapper);
        if (isCrazy) {
            Map<String, Object> m323d = CgformUtil.m323d(tbname, list, json);
            addOnlineUpdateDataLog(tbname, m323d.get("id").toString(), list, json);
            this.onlCgformFieldMapper.executeUpdatetSQL(m323d);
            return;
        }
        Map<String, Object> m341b = CgformUtil.m341b(tbname, list, json);
        addOnlineUpdateDataLog(tbname, m341b.get("id").toString(), list, json);
        this.onlCgformFieldMapper.executeUpdatetSQL(m341b);
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public void editTreeFormData(String code, String tbname, JSONObject json, String hasChildField, String pidField) {
        Integer queryCountBySql;
        String m317f = CgformUtil.m317f(tbname);
        QueryWrapper<?> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", json.getString("id"));
        String obj = CgformUtil.m361a((Map<String, Object>) m250a(m317f, (String) null, queryWrapper, JSONObject.class)).get(pidField).toString();
        LambdaQueryWrapper<OnlCgformField> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, code);
        List<OnlCgformField> list = list(lambdaQueryWrapper);
        for (OnlCgformField onlCgformField : list) {
            if (pidField.equals(onlCgformField.getDbFieldName()) && oConvertUtils.isEmpty(json.get(pidField))) {
                onlCgformField.setIsShowForm(1);
                json.put(pidField, "0");
            }
        }
        Map<String, Object> m341b = CgformUtil.m341b(tbname, list, json);
        addOnlineUpdateDataLog(tbname, m341b.get("id").toString(), list, json);
        ((OnlCgformFieldMapper) this.baseMapper).executeUpdatetSQL(m341b);
        if (!obj.equals(json.getString(pidField))) {
            JSONObject jSONObject = new JSONObject();
            if (!"0".equals(obj) && ((queryCountBySql = queryCountBySql(m317f, pidField, obj)) == null || queryCountBySql.intValue() == 0)) {
                jSONObject.put(hasChildField, "0");
                UpdateWrapper<?> updateWrapper = new UpdateWrapper<>();
                updateWrapper.eq("id", obj);
                m255a(m317f, jSONObject, updateWrapper);
            }
            if (!"0".equals(json.getString(pidField))) {
                jSONObject.put(hasChildField, "1");
                UpdateWrapper<?> updateWrapper2 = new UpdateWrapper<>();
                updateWrapper2.eq("id", json.getString(pidField));
                m255a(m317f, jSONObject, updateWrapper2);
            }
        }
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public Map<String, Object> queryFormData(String code, String tbname, String id) {
        LambdaQueryWrapper<OnlCgformField> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, code);
        lambdaQueryWrapper.eq(OnlCgformField::getIsShowForm, 1);
        return (Map) m253a(tbname, CgformUtil.m366a((List<OnlCgformField>) list(lambdaQueryWrapper), id), JSONObject.class);
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    @Transactional(rollbackFor = {Exception.class})
    public void deleteAutoListMainAndSub(OnlCgformHead head, String ids) {
        String[] split;
        String[] split2;
        List list;
        if (head.getTableType().intValue() == 2) {
            String id = head.getId();
            String tableName = head.getTableName();
            ArrayList<Map> arrayList = new ArrayList();
            if (oConvertUtils.isNotEmpty(head.getSubTableStr())) {
                for (String str : head.getSubTableStr().split(CgformUtil.f233E)) {
                    OnlCgformHead onlCgformHead = this.cgformHeadMapper.selectOne(new LambdaQueryWrapper<OnlCgformHead>().eq(OnlCgformHead::getTableName, str));
                    if (onlCgformHead != null && (list = list(new LambdaQueryWrapper<OnlCgformField> ().eq(OnlCgformField::getCgformHeadId, onlCgformHead.getId())
                    		.eq(OnlCgformField::getMainTable, head.getTableName()))) != null && list.size() != 0) {
                        OnlCgformField onlCgformField = (OnlCgformField) list.get(0);
                        Map hashMap = new HashMap(5);
                        hashMap.put("linkField", onlCgformField.getDbFieldName());
                        hashMap.put("mainField", onlCgformField.getMainField());
                        hashMap.put("tableName", str);
                        hashMap.put("linkValueStr", "");
                        arrayList.add(hashMap);
                    }
                }
                LambdaQueryWrapper<OnlCgformField>  lambdaQueryWrapper = new LambdaQueryWrapper();
                lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, id);
                List list2 = list(lambdaQueryWrapper);
                for (String str2 : ids.split(CgformUtil.f233E)) {
                    if (str2.indexOf("@") > 0) {
                        str2 = str2.substring(0, str2.indexOf("@"));
                    }
                    Map map = (Map) m253a(tableName, CgformUtil.m366a((List<OnlCgformField>) list2, str2), JSONObject.class);
                    new ArrayList();
                    for (Map map2 : arrayList) {
                        Object obj = map.get(((String) map2.get("mainField")).toLowerCase());
                        if (obj == null) {
                            obj = map.get(((String) map2.get("mainField")).toUpperCase());
                        }
                        if (obj != null) {
                            map2.put("linkValueStr", ((String) map2.get("linkValueStr")) + String.valueOf(obj) + CgformUtil.f233E);
                        }
                    }
                }
                for (Map map3 : arrayList) {
                    deleteAutoList((String) map3.get("tableName"), (String) map3.get("linkField"), (String) map3.get("linkValueStr"));
                }
            }
            deleteAutoListById(head.getTableName(), ids);
        }
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public void deleteAutoListById(String tbname, String ids) {
        deleteAutoList(tbname, "id", ids);
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public void deleteAutoList(String tbname, String linkField, String linkValue) {
        if (linkValue != null && !"".equals(linkValue)) {
            String[] split = linkValue.split(CgformUtil.f233E);
            ArrayList arrayList = new ArrayList();
            for (String str : split) {
                if (str != null && !"".equals(str)) {
                    if (str.indexOf("@") > 0) {
                        str = str.substring(0, str.indexOf("@"));
                    }
                    arrayList.add(str);
                }
            }
            QueryWrapper<?> queryWrapper = new QueryWrapper<>();
            queryWrapper.in(SqlInjectionUtil.getSqlInjectField(linkField), arrayList.toArray());
            m254a(CgformUtil.m317f(tbname), queryWrapper);
        }
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public List<Map<String, String>> getAutoListQueryInfo(String code) {
        String subTableStr;
        OnlCgformHead onlCgformHead = (OnlCgformHead) this.cgformHeadMapper.selectOne(new LambdaQueryWrapper<OnlCgformHead>().eq(OnlCgformHead::getId, code));
        ArrayList arrayList = new ArrayList();
        boolean m349a = CgformUtil.m349a(onlCgformHead);
        int m223a = m223a(onlCgformHead, arrayList, 0, m349a);
        Integer tableType = onlCgformHead.getTableType();
        if (m349a && tableType != null && 2 == tableType.intValue() && (subTableStr = onlCgformHead.getSubTableStr()) != null && !"".equals(subTableStr)) {
            for (String str : subTableStr.split(CgformUtil.f233E)) {
                OnlCgformHead onlCgformHead2 = (OnlCgformHead) this.cgformHeadMapper.selectOne( new LambdaQueryWrapper<OnlCgformHead>().eq(OnlCgformHead::getTableName, str));
                if (onlCgformHead2 != null) {
                    m223a = m223a(onlCgformHead2, (List<Map<String, String>>) arrayList, m223a, true);
                }
            }
        }
        return arrayList;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public List<OnlCgformField> queryFormFields(String code, boolean isform) {
        LambdaQueryWrapper<OnlCgformField> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, code);
        if (isform) {
            lambdaQueryWrapper.eq(OnlCgformField::getIsShowForm, 1);
        }
        return list(lambdaQueryWrapper);
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public List<OnlCgformField> queryFormFieldsByTableName(String tableName) {
        OnlCgformHead onlCgformHead = this.cgformHeadMapper.selectOne(new LambdaQueryWrapper<OnlCgformHead>().eq(OnlCgformHead::getTableName, tableName));
        if (onlCgformHead != null) {
            LambdaQueryWrapper<OnlCgformField> lambdaQueryWrapper = new LambdaQueryWrapper();
            lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, onlCgformHead.getId());
            return list(lambdaQueryWrapper);
        }
        return null;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public OnlCgformField queryFormFieldByTableNameAndField(String tableName, String fieldName) {
        OnlCgformHead onlCgformHead = this.cgformHeadMapper.selectOne( new LambdaQueryWrapper<OnlCgformHead>().eq(OnlCgformHead::getTableName, tableName));
        if (onlCgformHead != null) {
            LambdaQueryWrapper<OnlCgformField> lambdaQueryWrapper = new LambdaQueryWrapper();
            lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, onlCgformHead.getId());
            lambdaQueryWrapper.eq(OnlCgformField::getDbFieldName, fieldName);
            if (list(lambdaQueryWrapper) != null && list(lambdaQueryWrapper).size() > 0) {
                return (OnlCgformField) list(lambdaQueryWrapper).get(0);
            }
            return null;
        }
        return null;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public Map<String, Object> queryFormData(List<OnlCgformField> fieldList, String tbname, String id) {
        return (Map) m253a(tbname, CgformUtil.m366a(fieldList, id), JSONObject.class);
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public Map<String, Object> generateMockData(String tableName) {
        List<OnlCgformField> queryFormFieldsByTableName = queryFormFieldsByTableName(tableName);
        HashMap hashMap = new HashMap();
        if (queryFormFieldsByTableName == null || queryFormFieldsByTableName.size() == 0) {
            return hashMap;
        }
        for (OnlCgformField onlCgformField : queryFormFieldsByTableName) {
            hashMap.put(onlCgformField.getDbFieldName(), "");
        }
        return hashMap;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public List<Map<String, Object>> querySubFormData(List<OnlCgformField> fieldList, String tbname, String linkField, String value) {
        return (List) ((Collection) m253a(tbname, CgformUtil.m365a(fieldList, linkField, value), Collection.class)).stream().map(obj -> {
            return (JSONObject) obj;
        }).collect(Collectors.toList());
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public List<String> selectOnlineHideColumns(String tbname) {
    	LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    	List<String>  hideColumns = this.baseMapper.selectOnlineHideColumns(loginUser.getId(), "online:" + tbname + ":%");
        return hideColumns;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public List<OnlCgformField> queryAvailableFields(String cgFormId, String tbname, String taskId, boolean isList) {
        List<String> selectFlowAuthColumns;
        LambdaQueryWrapper<OnlCgformField>  lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, cgFormId);
        if (isList) {
            lambdaQueryWrapper.eq(OnlCgformField::getIsShowList, 1);
        } else {
            lambdaQueryWrapper.eq(OnlCgformField::getIsShowForm, 1);
        }
        lambdaQueryWrapper.orderByAsc(OnlCgformField::getOrderNum);
        List<OnlCgformField> list = list(lambdaQueryWrapper);
        String str = "online:" + tbname + "%";
        String id = ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getId();
        List<String> arrayList = new ArrayList<>();
        if (oConvertUtils.isEmpty(taskId)) {
            List<String> queryHideCode = this.onlAuthPageService.queryHideCode(id, cgFormId, isList);
            if (queryHideCode != null && queryHideCode.size() != 0 && queryHideCode.get(0) != null) {
                arrayList.addAll(queryHideCode);
            }
        } else if (oConvertUtils.isNotEmpty(taskId) && (selectFlowAuthColumns = ((OnlCgformFieldMapper) this.baseMapper).selectFlowAuthColumns(tbname, taskId, "1")) != null && selectFlowAuthColumns.size() > 0 && selectFlowAuthColumns.get(0) != null) {
            arrayList.addAll(selectFlowAuthColumns);
        }
        if (arrayList.size() == 0) {
            return list;
        }
        ArrayList arrayList2 = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            OnlCgformField onlCgformField = list.get(i);
            if (m217b(onlCgformField.getDbFieldName(), arrayList)) {
                arrayList2.add(onlCgformField);
            }
        }
        return arrayList2;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public List<String> queryDisabledFields(String tbname) {
        return m237a(((OnlCgformFieldMapper) this.baseMapper).selectOnlineDisabledColumns(((LoginUser) SecurityUtils.getSubject().getPrincipal()).getId(), "online:" + tbname + "%"));
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public List<String> queryDisabledFields(String tbname, String taskId) {
        if (oConvertUtils.isEmpty(taskId)) {
            return null;
        }
        return m237a(((OnlCgformFieldMapper) this.baseMapper).selectFlowAuthColumns(tbname, taskId, "2"));
    }

    /* renamed from: a */
    private List<String> m237a(List<String> list) {
        ArrayList arrayList = new ArrayList();
        if (list == null || list.size() == 0 || list.get(0) == null) {
            return arrayList;
        }
        for (String str : list) {
            if (!oConvertUtils.isEmpty(str)) {
                String substring = str.substring(str.lastIndexOf(":") + 1);
                if (!oConvertUtils.isEmpty(substring)) {
                    arrayList.add(substring);
                }
            }
        }
        return arrayList;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public List<OnlCgformField> queryAvailableFields(String tbname, boolean isList, List<OnlCgformField> List, List<String> needList) {
    	LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    	List<String>  hideColumns = this.baseMapper.selectOnlineHideColumns(loginUser.getId(), "online:" + tbname + "%");
        return List;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public List<OnlCgformField> queryAvailableFields(String cgformId, String tbname, boolean isList, List<OnlCgformField> fieldList, List<String> needList) {
    	LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    	List<String> hideColumns = this.onlAuthPageService.queryListHideColumn(loginUser.getId(), cgformId);
        return fieldList;//m232a(hideColumns, isList, fieldList, needList);
    }

    /* renamed from: b */
    private boolean m217b(String str, List<String> list) {
        boolean z = true;
        for (int i = 0; i < list.size(); i++) {
            String str2 = list.get(i);
            if (!oConvertUtils.isEmpty(str2)) {
                String substring = str2.substring(str2.lastIndexOf(":") + 1);
                if (!oConvertUtils.isEmpty(substring) && substring.equals(str)) {
                    z = false;
                }
            }
        }
        return z;
    }

    /* renamed from: a */
    public boolean m243a(String str, List<OnlCgformField> list) {
        boolean z = false;
        Iterator<OnlCgformField> it = list.iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            if (oConvertUtils.camelToUnderline(str).equals(it.next().getDbFieldName())) {
                z = true;
                break;
            }
        }
        return z;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public void executeInsertSQL(Map<String, Object> params) {
        ((OnlCgformFieldMapper) this.baseMapper).executeInsertSQL(params);
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public void executeUpdatetSQL(Map<String, Object> params) {
        ((OnlCgformFieldMapper) this.baseMapper).executeUpdatetSQL(params);
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public List<TreeModel> queryDataListByLinkDown(LinkDown linkDown) {
        linkDown.setTable(SqlInjectionUtil.getSqlInjectTableName(linkDown.getTable()));
        linkDown.setKey(SqlInjectionUtil.getSqlInjectField(linkDown.getKey()));
        linkDown.setTxt(SqlInjectionUtil.getSqlInjectField(linkDown.getTxt()));
        linkDown.setIdField(SqlInjectionUtil.getSqlInjectField(linkDown.getIdField()));
        linkDown.setPidField(SqlInjectionUtil.getSqlInjectField(linkDown.getPidField()));
        if (oConvertUtils.isNotEmpty(linkDown.getLinkField())) {
            linkDown.setLinkField(SqlInjectionUtil.getSqlInjectField(new String[0]));
        }
        QueryWrapper<?> queryWrapper = new QueryWrapper<>();
        queryWrapper.select(new String[]{linkDown.getKey() + " as store", linkDown.getTxt() + " as label", linkDown.getIdField() + " as id", linkDown.getPidField() + " as pid"});
        if (oConvertUtils.isNotEmpty(linkDown.getPidValue())) {
            queryWrapper.eq(linkDown.getPidField(), linkDown.getPidValue());
        } else if (oConvertUtils.isNotEmpty(linkDown.getCondition())) {
            SqlInjectionUtil.specialFilterContentForDictSql(linkDown.getCondition());
            queryWrapper.apply(linkDown.getCondition(), new Object[0]);
        }
        List<JSONObject> lists = m253a(linkDown.getTable(), queryWrapper, List.class);
        return lists.stream().map(jSONObject -> {  return  jSONObject.toJavaObject(TreeModel.class);  }).collect(Collectors.toList());
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public void updateTreeNodeNoChild(String tableName, String filed, String id) {
        ((OnlCgformFieldMapper) this.baseMapper).executeUpdatetSQL(CgformUtil.m375a(tableName, filed, id));
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public String queryTreeChildIds(OnlCgformHead head, String ids) {
        String treeParentIdField = head.getTreeParentIdField();
        String tableName = head.getTableName();
        String[] split = ids.split(CgformUtil.f233E);
        StringBuffer stringBuffer = new StringBuffer();
        for (String str : split) {
            if (str != null && !stringBuffer.toString().contains(str)) {
                if (stringBuffer.toString().length() > 0) {
                    stringBuffer.append(CgformUtil.f233E);
                }
                stringBuffer.append(str);
                m247a(str, treeParentIdField, tableName, stringBuffer);
            }
        }
        return stringBuffer.toString();
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public String queryTreePids(OnlCgformHead head, String ids) {
        QueryWrapper<?> queryWrapper = null;
        String treeParentIdField = head.getTreeParentIdField();
        String tableName = head.getTableName();
        StringBuffer stringBuffer = new StringBuffer();
        String[] split = ids.split(CgformUtil.f233E);
        for (String str : split) {
            if (str != null) {
                String m317f = CgformUtil.m317f(tableName);
                new QueryWrapper<>().eq("id", str);
                String obj = CgformUtil.m361a((Map<String, Object>) m250a(m317f, (String) null, queryWrapper, JSONObject.class)).get(treeParentIdField).toString();
                List<Map<String, Object>> queryListBySql = queryListBySql(m317f, null, treeParentIdField, obj, CgformUtil.f231C + String.join("','", split) + CgformUtil.f231C);
                if ((queryListBySql == null || queryListBySql.size() == 0) && !Arrays.asList(split).contains(obj) && !stringBuffer.toString().contains(obj)) {
                    stringBuffer.append(obj).append(CgformUtil.f233E);
                }
            }
        }
        return stringBuffer.toString();
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public String queryForeignKey(String cgFormId, String mainTable) {
        LambdaQueryWrapper<OnlCgformField> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, cgFormId);
        lambdaQueryWrapper.eq(OnlCgformField::getMainTable, mainTable);
        List list = list(lambdaQueryWrapper);
        if (list != null && list.size() > 0) {
            return ((OnlCgformField) list.get(0)).getMainField();
        }
        return null;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public List<Map<String, Object>> queryListBySql(String tableName, String fields, String pidField, String metaPid, String inIds) {
        QueryWrapper<?> queryWrapper = new QueryWrapper<>();
        if (oConvertUtils.isNotEmpty(pidField)) {
            queryWrapper.eq(SqlInjectionUtil.getSqlInjectField(pidField), metaPid);
        }
        if (oConvertUtils.isNotEmpty(inIds)) {
            queryWrapper.in("id", Arrays.asList(inIds.split(CgformUtil.f233E)));
        }
        return (List) ((Collection) m250a(tableName, fields, queryWrapper, Collection.class)).stream().map(obj -> {
            return (JSONObject) obj;
        }).collect(Collectors.toList());
    }

    /* renamed from: a */
    private StringBuffer m247a(String str, String str2, String str3, StringBuffer stringBuffer) {
        List<Map<String, Object>> queryListBySql = queryListBySql(str3, null, str2, str, null);
        if (queryListBySql != null && queryListBySql.size() > 0) {
            for (Map<String, Object> map : queryListBySql) {
                Map<String, Object> m361a = CgformUtil.m361a(map);
                if (!stringBuffer.toString().contains(m361a.get("id").toString())) {
                    stringBuffer.append(CgformUtil.f233E).append(m361a.get("id"));
                }
                m247a(m361a.get("id").toString(), str2, str3, stringBuffer);
            }
        }
        return stringBuffer;
    }

    /* renamed from: a */
    private String m233a(List<OnlCgformField> list, Map<String, Object> map) {
        String string;
        Object obj = map.get("column");
        ArrayList<SqlOrder> arrayList = new ArrayList();
        if (obj != null && !"id".equals(obj.toString())) {
            String obj2 = obj.toString();
            Object obj3 = map.get("order");
            String str = "desc";
            if (obj3 != null) {
                str = obj3.toString();
            }
            arrayList.add(new SqlOrder(obj2, str));
        } else {
            for (OnlCgformField onlCgformField : list) {
                String fieldExtendJson = onlCgformField.getFieldExtendJson();
                SqlOrder sqlOrder = new SqlOrder(onlCgformField.getDbFieldName());
                if (oConvertUtils.isNotEmpty(fieldExtendJson) && fieldExtendJson.trim().startsWith("{") && fieldExtendJson.trim().endsWith("}") && (string = JSON.parseObject(fieldExtendJson).getString(ExtendJsonKey.f135h)) != null && !"".equals(string)) {
                    sqlOrder.setRule(string);
                    arrayList.add(sqlOrder);
                }
            }
            if (arrayList.size() == 0) {
                arrayList.add(SqlOrder.m263a());
            }
        }
        List arrayList2 = new ArrayList();
        for (SqlOrder sqlOrder2 : arrayList) {
            if (m243a(sqlOrder2.getColumn(), list)) {
                arrayList2.add(sqlOrder2.getRealSql());
            }
        }
        if(CollUtil.isEmpty(arrayList2)) {
        	return "";
        }
        return " ORDER BY " + String.join(CgformUtil.f233E, arrayList2);
    }

    /* renamed from: a */
    private int m223a(OnlCgformHead onlCgformHead, List<Map<String, String>> list, int i, boolean z) {
        LambdaQueryWrapper<OnlCgformField> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, onlCgformHead.getId());
        lambdaQueryWrapper.eq(OnlCgformField::getIsQuery, 1);
        lambdaQueryWrapper.eq(OnlCgformField::getDbIsPersist, OnlineConst.f140b);
        lambdaQueryWrapper.orderByAsc(OnlCgformField::getOrderNum);
        for (OnlCgformField onlCgformField : list(lambdaQueryWrapper)) {
            HashMap hashMap = new HashMap(5);
            hashMap.put("label", onlCgformField.getDbFieldTxt());
            if (z) {
                hashMap.put("field", onlCgformHead.getTableName() + "@" + onlCgformField.getDbFieldName());
            } else {
                hashMap.put("field", onlCgformField.getDbFieldName());
            }
            hashMap.put("dbField", onlCgformField.getDbFieldName());
            hashMap.put("mode", onlCgformField.getQueryMode());
            if (oConvertUtils.isNotEmpty(onlCgformField.getFieldExtendJson())) {
                hashMap.put("fieldExtendJson", onlCgformField.getFieldExtendJson());
            }
            if ("1".equals(onlCgformField.getQueryConfigFlag())) {
                String queryShowType = onlCgformField.getQueryShowType();
                hashMap.put("config", "1");
                hashMap.put(CgformUtil.view, queryShowType);
                hashMap.put("defValue", onlCgformField.getQueryDefVal());
                if (CgformUtil.f247S.equals(queryShowType)) {
                    hashMap.put("pcode", onlCgformField.getQueryDictField());
                } else if (CgformUtil.f246R.equals(queryShowType)) {
                    String[] split = onlCgformField.getQueryDictText().split(CgformUtil.f233E);
                    hashMap.put("dict", onlCgformField.getQueryDictTable() + CgformUtil.f233E + split[2] + CgformUtil.f233E + split[0]);
                    hashMap.put("pidField", split[1]);
                    hashMap.put("hasChildField", split[3]);
                    hashMap.put("pidValue", onlCgformField.getQueryDictField());
                } else {
                    hashMap.put("dictTable", onlCgformField.getQueryDictTable());
                    hashMap.put("dictCode", onlCgformField.getQueryDictField());
                    hashMap.put("dictText", onlCgformField.getQueryDictText());
                }
            } else {
                String fieldShowType = onlCgformField.getFieldShowType();
                hashMap.put(CgformUtil.view, fieldShowType);
                hashMap.put("mode", onlCgformField.getQueryMode());
                if (CgformUtil.f247S.equals(fieldShowType)) {
                    hashMap.put("pcode", onlCgformField.getDictField());
                } else if (CgformUtil.f246R.equals(fieldShowType)) {
                    String[] split2 = onlCgformField.getDictText().split(CgformUtil.f233E);
                    hashMap.put("dict", onlCgformField.getDictTable() + CgformUtil.f233E + split2[2] + CgformUtil.f233E + split2[0]);
                    hashMap.put("pidField", split2[1]);
                    hashMap.put("hasChildField", split2[3]);
                    hashMap.put("pidValue", onlCgformField.getDictField());
                } else {
                    hashMap.put("dictTable", onlCgformField.getDictTable());
                    hashMap.put("dictCode", onlCgformField.getDictField());
                    hashMap.put("dictText", onlCgformField.getDictText());
                }
            }
            i++;
            if (i > 2) {
                hashMap.put("hidden", "1");
            }
            list.add(hashMap);
        }
        return i;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    @CacheEvict(value = {"sys:cache:online:list", "sys:cache:online:form"}, allEntries = true, beforeInvocation = true)
    public void clearCacheOnlineConfig() {
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public OnlQueryModel getQueryInfo(OnlCgformHead head, Map<String, Object> params, List<String> needList) {
        List<OnlCgformField> queryAvailableFields;
        String sqlInjectTableName = SqlInjectionUtil.getSqlInjectTableName(head.getTableName());
        String id = head.getId();
        LambdaQueryWrapper<OnlCgformField> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgformField::getCgformHeadId, id);
        lambdaQueryWrapper.eq(OnlCgformField::getDbIsPersist, OnlineConst.f140b);
        lambdaQueryWrapper.orderByAsc(OnlCgformField::getOrderNum);
        List list = list(lambdaQueryWrapper);
        new ArrayList();
        List<String> selectFieldList = head.getSelectFieldList();
        if (selectFieldList != null && selectFieldList.size() > 0) {
            queryAvailableFields = m242a(id, list, selectFieldList, needList);
        } else {
            queryAvailableFields = queryAvailableFields(id, sqlInjectTableName, true, list, needList);
        }
        StringBuffer stringBuffer = new StringBuffer();
        CgformUtil.m371a(sqlInjectTableName, queryAvailableFields, stringBuffer);
        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        List<SysPermissionDataRuleModel> queryUserOnlineAuthData = this.onlAuthDataService.queryUserOnlineAuthData(loginUser.getId(), id);
        if (queryUserOnlineAuthData != null && queryUserOnlineAuthData.size() > 0) {
            JeecgDataAutorUtils.installUserInfo(this.sysBaseAPI.getCacheUser(loginUser.getUsername()));
        }
        ConditionHandler conditionHandler = new ConditionHandler("t.", DbTableUtil.m27c((DataBaseConfig) null).getDb());
        conditionHandler.setTableName(sqlInjectTableName);
        conditionHandler.setNeedList(needList);
        conditionHandler.setSubTableStr(head.getSubTableStr());
        String m563a = conditionHandler.m563a(CgformUtil.m313g(list), params, queryUserOnlineAuthData);
        Map<String, Object> sqlParams = conditionHandler.getSqlParams();
        if (m563a.trim().length() > 0) {
            stringBuffer.append(" t ").append(CgformUtil.f211i).append(m563a);
        }
        stringBuffer.append(m233a(list, params));
        OnlQueryModel onlQueryModel = new OnlQueryModel(stringBuffer.toString(), sqlParams);
        onlQueryModel.setFieldList(queryAvailableFields);
        return onlQueryModel;
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public void addOnlineInsertDataLog(String tableName, String dataId) {
        f455a.execute(() -> {
            this.sysBaseAPI.saveDataLog(new DataLogDTO(tableName, dataId, " 创建了记录", "comment"));
        });
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public void addOnlineUpdateDataLog(String tableName, String dataId, List<OnlCgformField> fieldList, JSONObject json) {
        String m317f = CgformUtil.m317f(tableName);
        LambdaQueryWrapper<OnlCgformHead> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.select(OnlCgformHead::getTableType,OnlCgformHead::getTableTxt,OnlCgformHead::getSubTableStr);
        lambdaQueryWrapper.eq(OnlCgformHead::getTableName, m317f);
        OnlCgformHead onlCgformHead = this.cgformHeadMapper.selectOne(lambdaQueryWrapper);
        if (onlCgformHead == null) {
            return;
        }
        HashSet<String> hashSet = new HashSet();
        if (oConvertUtils.isNotEmpty(onlCgformHead.getSubTableStr())) {
            hashSet.addAll((Collection) Arrays.stream(onlCgformHead.getSubTableStr().split(CgformUtil.f233E)).collect(Collectors.toSet()));
        }
        Map<String, Object> m251a = m251a(m317f, dataId);
        if (m251a != null) {
            StringBuilder sb = new StringBuilder();
            if (hashSet.size() > 0) {
                for (String str : hashSet) {
                    String m317f2 = CgformUtil.m317f(str);
                    String m256a = m256a(m317f2, json.getJSONArray(m317f2), m317f, dataId);
                    if (oConvertUtils.isNotEmpty(m256a)) {
                        sb.append(m256a).append("；");
                    }
                }
            }
            String tokenByRequest = TokenUtils.getTokenByRequest();
            f455a.execute(() -> {
                UserTokenContext.setToken(tokenByRequest);
                DataLogDTO dataLogDTO = new DataLogDTO(m317f, dataId, "comment");
                StringBuilder sb2 = new StringBuilder(m236a(fieldList, json, m251a));
                if (sb.length() > 0) {
                    sb2.append("；").append((CharSequence) sb);
                }
                String str2 = (String) Arrays.stream(sb2.toString().split("；")).filter(str3 -> {
                    return oConvertUtils.isNotEmpty(str3.trim());
                }).collect(Collectors.joining("；"));
                if (oConvertUtils.isNotEmpty(str2)) {
                    dataLogDTO.setContent(str2);
                    this.sysBaseAPI.saveDataLog(dataLogDTO);
                }
            });
        }
    }

    /* renamed from: a */
    private String m236a(List<OnlCgformField> list, JSONObject jSONObject, Map<String, Object> map) {
        String str;
        LocalDateTime localDateTime;
        StringBuffer stringBuffer = new StringBuffer();
        DateTimeFormatter ofPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        for (OnlCgformField onlCgformField : list) {
            String dbFieldName = onlCgformField.getDbFieldName();
            if (null != dbFieldName && !"id".equalsIgnoreCase(dbFieldName) && !CgformUtil.f229A.equalsIgnoreCase(dbFieldName) && !CgformUtil.f226x.equalsIgnoreCase(dbFieldName) && !CgformUtil.f228z.equalsIgnoreCase(dbFieldName) && !CgformUtil.f225w.equalsIgnoreCase(dbFieldName) && !CgformUtil.f227y.equalsIgnoreCase(dbFieldName)) {
                String dbType = onlCgformField.getDbType();
                if (!"blob".equalsIgnoreCase(dbType) && !ExtendJsonKey.f133f.equalsIgnoreCase(dbType) && (!oConvertUtils.isEmpty(jSONObject.get(dbFieldName)) || !oConvertUtils.isEmpty(map.get(dbFieldName)))) {
                    String str2 = "空";
                    if (jSONObject.get(dbFieldName) == null) {
                        str = "空";
                    } else {
                        String obj = jSONObject.get(dbFieldName).toString();
                        if (obj.length() == 0) {
                            str = "空";
                        } else {
                            str = obj;
                        }
                    }
                    if ("Datetime".equalsIgnoreCase(dbType)) {
                        if (map.get(dbFieldName) != null) {
                            Object obj2 = map.get(dbFieldName);
                            if (obj2 instanceof Timestamp) {
                                localDateTime = LocalDateTime.ofInstant(((Timestamp) obj2).toInstant(), ZoneId.systemDefault());
                            } else {
                                localDateTime = (LocalDateTime) map.get(dbFieldName);
                            }
                            str2 = ofPattern.format(localDateTime);
                        }
                    } else if ("BigDecimal".equalsIgnoreCase(dbType) || "double".equalsIgnoreCase(dbType)) {
                        Integer dbPointLength = onlCgformField.getDbPointLength();
                        if (map.get(dbFieldName) != null) {
                            str2 = map.get(dbFieldName).toString();
                        }
                        if (jSONObject.get(dbFieldName) == null || jSONObject.get(dbFieldName).toString().length() == 0) {
                            str = "空";
                        } else {
                            String obj3 = jSONObject.get(dbFieldName).toString();
                            if (obj3.indexOf(".") < 0) {
                                obj3 = obj3 + ".";
                            }
                            if ((obj3.length() - 1) - obj3.indexOf(".") < dbPointLength.intValue()) {
                                do {
                                    obj3 = obj3 + "0";
                                } while ((obj3.length() - 1) - obj3.indexOf(".") < dbPointLength.intValue());
                                str = obj3;
                            } else {
                                str = obj3;
                            }
                        }
                    } else if (map.get(dbFieldName) != null) {
                        str2 = map.get(dbFieldName).toString();
                        if (str2.length() == 0) {
                            str2 = "空";
                        }
                    }
                    if (!str2.equals(str) && (!"double".equalsIgnoreCase(dbType) || map.get(dbFieldName) == null || jSONObject.get(dbFieldName) == null || new BigDecimal(map.get(dbFieldName).toString()).compareTo(new BigDecimal(jSONObject.get(dbFieldName).toString())) != 0)) {
                        if (oConvertUtils.isNotEmpty(onlCgformField.getDictField()) && !CgformUtil.f241M.equalsIgnoreCase(onlCgformField.getFieldShowType())) {
                            String[] m229a = m229a(onlCgformField, str2, str);
                            if (m229a.length == 2) {
                                str2 = m229a[0];
                                str = m229a[1];
                            }
                        }
                        stringBuffer.append("  将名称为【" + onlCgformField.getDbFieldTxt() + "】的字段内容 " + str2 + " 修改为 " + str + "；  ");
                    }
                }
            }
        }
        return stringBuffer.toString();
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r0v52, types: [java.util.List] */
    /* JADX WARN: Type inference failed for: r0v55, types: [java.util.List] */
    /* renamed from: a */
    private String[] m229a(OnlCgformField onlCgformField, String str, String str2) {
        String dictField;
        List<DictModel> list = null;
        if (CgformUtil.f242N.equalsIgnoreCase(onlCgformField.getFieldShowType())) {
            Map<Object, List<Map<String, Object>>> m248a = m248a(onlCgformField.getDictTable(), onlCgformField.getDictField(), onlCgformField.getDictText(), str + CgformUtil.f233E + str2);
            System.out.println(m248a);
            if (null != m248a && !m248a.isEmpty()) {
                list = (List) m248a.values().stream().filter((v0) -> {
                    return Objects.nonNull(v0);
                }).map(list2 -> {
                    return new DictModel(((Map) list2.get(0)).get(onlCgformField.getDictField()) + "", ((Map) list2.get(0)).get(onlCgformField.getDictText()) + "");
                }).collect(Collectors.toList());
            }
        } else {
            if (oConvertUtils.isNotEmpty(onlCgformField.getDictTable())) {
                dictField = onlCgformField.getDictTable() + CgformUtil.f233E + onlCgformField.getDictText() + CgformUtil.f233E + onlCgformField.getDictField();
            } else {
                dictField = onlCgformField.getDictField();
            }
            list = this.sysBaseAPI.getDictItems(dictField);
        }
        if (oConvertUtils.listIsNotEmpty(list)) {
            List arrayList = new ArrayList();
            if (str.contains(CgformUtil.f233E)) {
                arrayList = Arrays.asList(str.split(CgformUtil.f233E));
            } else {
                arrayList.add(str);
            }
            List arrayList2 = new ArrayList();
            if (str2.contains(CgformUtil.f233E)) {
                arrayList2 = Arrays.asList(str2.split(CgformUtil.f233E));
            } else {
                arrayList2.add(str);
            }
            for (DictModel dictModel : list) {
                m230a(dictModel, arrayList);
                m230a(dictModel, arrayList2);
            }
            if (oConvertUtils.listIsNotEmpty(arrayList)) {
                str = String.join(CgformUtil.f233E, arrayList);
            }
            if (oConvertUtils.listIsNotEmpty(arrayList2)) {
                str2 = String.join(CgformUtil.f233E, arrayList2);
            }
        }
        return new String[]{str, str2};
    }

    /* renamed from: a */
    private static void m230a(DictModel dictModel, List<String> list) {
        String value = dictModel.getValue();
        if (oConvertUtils.listIsNotEmpty(list) && list.contains(value)) {
            list.replaceAll(str -> {
                if (str.equalsIgnoreCase(value)) {
                    return dictModel.getText();
                }
                return str;
            });
        }
    }

    /* renamed from: a */
    private String m256a(String str, JSONArray jSONArray, String str2, String str3) {
        OnlCgformField onlCgformField = null;
        if (jSONArray == null) {
            return "";
        }
        LambdaQueryWrapper<OnlCgformHead> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.select(OnlCgformHead::getId,OnlCgformHead::getTableTxt,OnlCgformHead::getRelationType);
        lambdaQueryWrapper.eq(OnlCgformHead::getTableName, str);
        OnlCgformHead onlCgformHead = (OnlCgformHead) this.cgformHeadMapper.selectOne(lambdaQueryWrapper);
        if (onlCgformHead == null) {
            return "";
        }
        LambdaQueryWrapper<OnlCgformField> lambdaQueryWrapper2 = new LambdaQueryWrapper();
        lambdaQueryWrapper2.eq(OnlCgformField::getCgformHeadId, onlCgformHead.getId());
        List<OnlCgformField>  list = list(lambdaQueryWrapper2);
        if (list == null || list.size() == 0 || (list.stream().filter(onlCgformField2 -> {
            return str2.equals(onlCgformField2.getMainTable());
        }).findFirst().orElse(null)) == null) {
            return "";
        }
        StringBuilder sb = new StringBuilder();
        QueryWrapper<?> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(onlCgformField.getDbFieldName(), str3);
        List list2 = (List) m250a(str, (String) null, queryWrapper, List.class);
        if (list2 == null || list2.isEmpty()) {
            if (jSONArray.isEmpty()) {
                return "";
            }
            sb.append("新增了").append(jSONArray.size()).append("条数据，");
        } else if (jSONArray.isEmpty()) {
            sb.append("删除了").append(list2.size()).append("条数据，");
        } else if (CgformConstant.f372g.equals(onlCgformHead.getRelationType())) {
            String m236a = m236a((List) list.stream().filter(onlCgformField3 -> {
                return onlCgformField3 != onlCgformField;
            }).collect(Collectors.toList()), jSONArray.getJSONObject(0), ((JSONObject) list2.get(0)).getInnerMap());
            if (oConvertUtils.isEmpty(m236a)) {
                return "";
            }
            sb.append("子表[").append(onlCgformHead.getTableTxt()).append("]：");
            return sb.append(m236a).toString();
        } else {
            AtomicInteger atomicInteger = new AtomicInteger();
            int i = 0;
            int i2 = 0;
            Set set = (Set) list2.stream().map(obj -> {
                return ((JSONObject) obj).getString("id");
            }).collect(Collectors.toSet());
            HashSet hashSet = new HashSet();
            for (int i3 = 0; i3 < jSONArray.size(); i3++) {
                String string = jSONArray.getJSONObject(i3).getString("id");
                if (oConvertUtils.isEmpty(string)) {
                    atomicInteger.getAndIncrement();
                } else {
                    hashSet.add(string);
                }
            }
            HashSet<String> hashSet2 = new HashSet();
            hashSet2.addAll(set);
            hashSet2.addAll(hashSet);
            hashSet2.removeIf((v0) -> {
                return oConvertUtils.isEmpty(v0);
            });
            for (String str4 : hashSet2) {
                if (set.contains(str4) && !hashSet.contains(str4)) {
                    i2++;
                } else {
                    JSONObject jSONObject = null;
                    int i4 = 0;
                    while (true) {
                        if (i4 >= jSONArray.size()) {
                            break;
                        }
                        JSONObject jSONObject2 = jSONArray.getJSONObject(i4);
                        if (!str4.equals(jSONObject2.getString("id"))) {
                            i4++;
                        } else {
                            jSONObject = jSONObject2;
                            break;
                        }
                    }
                    JSONObject jSONObject3 = (JSONObject) list2.stream().filter(obj2 -> {
                        return str4.equals(((JSONObject) obj2).getString("id"));
                    }).findFirst().orElse(null);
                    if (jSONObject != null && jSONObject3 != null) {
                        Iterator it = list.iterator();
                        while (true) {
                            if (!it.hasNext()) {
                                break;
                            }
                            OnlCgformField onlCgformField4 = (OnlCgformField) it.next();
                            if (onlCgformField4 != onlCgformField) {
                                String dbFieldName = onlCgformField4.getDbFieldName();
                                if (!"id".equalsIgnoreCase(dbFieldName) && !CgformUtil.f229A.equalsIgnoreCase(dbFieldName) && !CgformUtil.f226x.equalsIgnoreCase(dbFieldName) && !CgformUtil.f228z.equalsIgnoreCase(dbFieldName) && !CgformUtil.f225w.equalsIgnoreCase(dbFieldName) && !CgformUtil.f227y.equalsIgnoreCase(dbFieldName)) {
                                    String string2 = jSONObject3.getString(dbFieldName);
                                    String string3 = jSONObject.getString(dbFieldName);
                                    if (oConvertUtils.isNotEmpty(string2) && oConvertUtils.isNotEmpty(string3) && !string2.equals(string3)) {
                                        i++;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (atomicInteger.get() > 0) {
                sb.append("新增了").append(atomicInteger.get()).append("条数据，");
            }
            if (i > 0) {
                sb.append("修改了").append(i).append("条数据，");
            }
            if (i2 > 0) {
                sb.append("删除了").append(i2).append("条数据，");
            }
        }
        if (sb.length() > 0) {
            sb.insert(0, "]：").insert(0, onlCgformHead.getTableTxt()).insert(0, "子表[");
        }
        String sb2 = sb.toString();
        if (sb2.endsWith("，")) {
            sb2 = sb2.substring(0, sb2.length() - 1);
        }
        return sb2;
    }

    /* renamed from: a */
    private Map<String, Object> m251a(String str, String str2) {
        QueryWrapper<?> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", str2);
        return (Map) m250a(str, (String) null, queryWrapper, JSONObject.class);
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    @Cacheable(value = {OnlineConst.f141c}, key = "#table+#textString+#code")
    public List<Map<String, Object>> queryLinkTableDictList(String table, String textString, String code) {
        return queryListBySql(table, textString + CgformUtil.f233E + code, null, null, null);
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public void handleLinkTableDictData(String headId, List<Map<String, Object>> dataList) {
        List<OnlCgformField> selectList;
        if (dataList != null && dataList.size() != 0 && (selectList = this.onlCgformFieldMapper.selectList( (new LambdaQueryWrapper<OnlCgformField>().eq(OnlCgformField::getCgformHeadId, headId))
        		.in(OnlCgformField::getFieldShowType, new String[]{CgformUtil.f264aj, CgformUtil.f263ai, CgformUtil.f242N}))) != null && selectList.size() > 0) {
            HashMap hashMap = new HashMap();
            for (OnlCgformField onlCgformField : selectList) {
                if (CgformUtil.f264aj.equals(onlCgformField.getFieldShowType())) {
                    String dictTable = onlCgformField.getDictTable();
                    List list = (List) hashMap.get(dictTable);
                    List arrayList = list;
                    if (list == null) {
                        arrayList = new ArrayList();
                    }
                    arrayList.add(onlCgformField.getDbFieldName() + CgformUtil.f233E + onlCgformField.getDictText());
                    hashMap.put(dictTable, arrayList);
                }
            }
            for (OnlCgformField onlCgformField2 : selectList) {
                if (CgformUtil.f263ai.equals(onlCgformField2.getFieldShowType())) {
                    String dictTable2 = onlCgformField2.getDictTable();
                    String dictText = onlCgformField2.getDictText();
                    String dictField = onlCgformField2.getDictField();
                    Map<String, List<DictModel>> m216b = m216b(m249a(dictTable2, dictText, dictField));
                    LambdaQueryWrapper<OnlCgformHead> lambdaQueryWrapper = new LambdaQueryWrapper();
                    lambdaQueryWrapper.eq(OnlCgformHead::getTableName, dictTable2);
                    OnlCgformHead onlCgformHead = (OnlCgformHead) this.cgformHeadMapper.selectOne(lambdaQueryWrapper);
                    if (onlCgformHead == null) {
                        throw new TuringBootException("未找到关联表【" + dictTable2 + "】的配置信息");
                    }
                    List<Map<String, Object>> queryLinkTableDictList = queryLinkTableDictList(dictTable2, dictText, dictField);
                    String lowerCase = onlCgformField2.getDbFieldName().toLowerCase();
                    String str = dictText.split(CgformUtil.f233E)[0];
                    for (Map<String, Object> map : dataList) {
                        Object obj = map.get(lowerCase);
                        if (obj != null && !"".equals(obj.toString())) {
                            map.put(lowerCase + "_dictText", m222a(onlCgformHead, m216b, queryLinkTableDictList, str, dictField, obj));
                            List<String> list2 = (List) hashMap.get(lowerCase);
                            if (list2 != null && list2.size() > 0) {
                                for (String str2 : list2) {
                                    String[] split = str2.split(CgformUtil.f233E);
                                    map.put(split[0].toLowerCase(), m222a(onlCgformHead, m216b, queryLinkTableDictList, split[1], dictField, obj));
                                }
                            }
                        }
                    }
                } else if (CgformUtil.f242N.equalsIgnoreCase(onlCgformField2.getFieldShowType())) {
                    String dictTable3 = onlCgformField2.getDictTable();
                    String dictText2 = onlCgformField2.getDictText();
                    String dictField2 = onlCgformField2.getDictField();
                    String str3 = (String) dataList.stream().map(map2 -> {
                        return map2.get(onlCgformField2.getDbFieldName().toLowerCase());
                    }).filter(Objects::nonNull).map((v0) -> {
                        return v0.toString();
                    }).collect(Collectors.joining(CgformUtil.f233E));
                    if (!str3.isEmpty()) {
                        Map<Object, List<Map<String, Object>>> m248a = m248a(dictTable3, dictField2, dictText2, (String) Arrays.stream(str3.split(CgformUtil.f233E)).distinct().collect(Collectors.joining(CgformUtil.f233E)));
                        dataList.forEach(map3 -> {
                            Object obj2 = map3.get(onlCgformField2.getDbFieldName().toLowerCase());
                            Object obj3 = obj2;
                            if (obj2 != null) {
                                obj3 = Arrays.stream(obj2.toString().split(CgformUtil.f233E)).map(str4 -> {
                                    List list3 = (List) m248a.get(str4);
                                    if (list3 != null && !list3.isEmpty()) {
                                        return ((Map) list3.get(0)).get(dictText2) + "";
                                    }
                                    return str4;
                                }).collect(Collectors.joining(CgformUtil.f233E));
                            }
                            map3.put(onlCgformField2.getDbFieldName().toLowerCase() + "_dictText", obj3);
                        });
                    }
                }
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r0v27, types: [java.util.Map] */
    /* renamed from: a */
    private Map<Object, List<Map<String, Object>>> m248a(String str, String str2, String str3, String str4) {
        Map hashMap;
        HashMap hashMap2 = new HashMap();
        hashMap2.put(CgReportConstant.f499E + str2, str4);
        f453b.info("popup字典字段翻译-查询online报表参数:" + JSONObject.toJSONString(hashMap2));
        Map<String, Object> map = null;
        try {
            map = this.onlCgreportAPIService.getDataByCode(str, hashMap2);
        } catch (Exception e) {
            f453b.error("查询字典数据失败:{}", e.getMessage(), e);
        }
        if (null != map && !map.isEmpty()) {
            if (((Long) map.get("total")).longValue() > 0) {
                List<Map<String, Object>> list = (List<Map<String, Object>>) map.get("records");
                System.out.println(list);
                hashMap = (Map) list.stream().filter((v0) -> {
                    return Objects.nonNull(v0);
                }).map(map2 -> {
                    HashMap hashMap3 = new HashMap(2);
                    hashMap3.put(str2, map2.get(str2));
                    hashMap3.put(str3, map2.get(str3));
                    return hashMap3;
                }).collect(Collectors.groupingBy(map3 -> {
                    return map3.get(str2);
                }));
            } else {
                hashMap = new HashMap();
            }
        } else {
            hashMap = new HashMap();
        }
        return hashMap;
    }

    /* renamed from: a */
    public void m224a(OnlCgformHead onlCgformHead, List<Map<String, Object>> list) {
        if (!"Y".equals(onlCgformHead.getIsTree())) {
            return;
        }
        String treeParentIdField = onlCgformHead.getTreeParentIdField();
        ArrayList arrayList = new ArrayList();
        HashMap hashMap = new HashMap();
        for (Map<String, Object> map : list) {
            String m360a = CgformUtil.m360a(map, treeParentIdField);
            if (!oConvertUtils.isEmpty(m360a) && !"0".equals(m360a)) {
                arrayList.add(m360a);
                ((List) hashMap.computeIfAbsent(m360a, str -> {
                    return new ArrayList();
                })).add(map);
            } else {
                map.put(treeParentIdField + "_dictText", " ");
            }
        }
        if (arrayList.isEmpty()) {
            return;
        }
        String treeFieldname = onlCgformHead.getTreeFieldname();
        HashMap hashMap2 = new HashMap();
        hashMap2.put(OnlineConst.f139a, treeParentIdField + CgformUtil.f233E + treeFieldname);
        hashMap2.put("pageNo", "1");
        hashMap2.put("pageSize", Integer.valueOf(arrayList.size()));
        hashMap2.put("superQueryMatchType", "and");
        hashMap2.put("superQueryParams", ("%5B%7B%22field%22:%22id%22,%22rule%22:%22in%22,%22val%22:%22" + String.join(CgformUtil.f233E, arrayList)) + "%22%7D%5D");
        Map<String, Object> queryAutolistPage = queryAutolistPage(onlCgformHead, hashMap2, new ArrayList());
        if (queryAutolistPage == null) {
            return;
        }
        JSONArray jSONArray = new JSONObject(queryAutolistPage).getJSONArray("records");
        for (int i = 0; i < jSONArray.size(); i++) {
            JSONObject jSONObject = jSONArray.getJSONObject(i);
            List<Map<String, Object>> list2 = (List<Map<String, Object>>) hashMap.get(CgformUtil.m360a((Map<String, Object>) jSONObject, "id"));
            if (!CollectionUtils.isEmpty(list2)) {
                String m360a2 = CgformUtil.m360a((Map<String, Object>) jSONObject, treeFieldname);
                if (oConvertUtils.isNotEmpty(m360a2)) {
                    list2.forEach(map2 -> {
                        map2.put(treeParentIdField + "_dictText", m360a2);
                    });
                }
            }
        }
    }

    /* renamed from: a */
    private List<OnlCgformField> m249a(String str, String str2, String str3) {
        OnlCgformHead onlCgformHead = this.cgformHeadMapper.selectOne(new LambdaQueryWrapper<OnlCgformHead>().eq(OnlCgformHead::getTableName, str));
        if (onlCgformHead == null) {
            throw new TuringBootException("实体未找到");
        }
        if (oConvertUtils.isEmpty(str2) || oConvertUtils.isEmpty(str3)) {
            throw new TuringBootException("关联记录字典参数不正确");
        }
        String[] split = str2.split(CgformUtil.f233E);
        ArrayList arrayList = new ArrayList();
        arrayList.add(str3);
        for (String str4 : split) {
            arrayList.add(str4);
        }
        return this.onlCgformFieldMapper.selectList( (new LambdaQueryWrapper<OnlCgformField>().eq(OnlCgformField::getCgformHeadId, onlCgformHead.getId())).in(OnlCgformField::getDbFieldName, arrayList));
    }

    /* renamed from: b */
    private Map<String, List<DictModel>> m216b(List<OnlCgformField> list) {
        HashMap hashMap = new HashMap();
        for (OnlCgformField onlCgformField : list) {
            String dictTable = onlCgformField.getDictTable();
            String dictText = onlCgformField.getDictText();
            String dictField = onlCgformField.getDictField();
            if (CgformUtil.m332c(onlCgformField.getFieldShowType())) {
                if (oConvertUtils.isNotEmpty(dictTable) && oConvertUtils.isNotEmpty(dictText) && oConvertUtils.isNotEmpty(dictField)) {
                    hashMap.put(onlCgformField.getDbFieldName(), this.sysBaseAPI.queryTableDictItemsByCode(dictTable, dictText, dictField));
                } else if (oConvertUtils.isNotEmpty(dictField)) {
                    hashMap.put(onlCgformField.getDbFieldName(), this.sysBaseAPI.queryDictItemsByCode(dictField));
                }
            }
        }
        return hashMap;
    }

    /* renamed from: a */
    private List<OnlCgformField> m242a(String str, List<OnlCgformField> list, List<String> list2, List<String> list3) {
        String id = ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getId();
        List<OnlCgformField> arrayList = new ArrayList();
        for (OnlCgformField onlCgformField : list) {
            if (list2.indexOf(onlCgformField.getDbFieldName()) >= 0) {
                arrayList.add(onlCgformField);
            }
        }
        List<String> hideColumns = this.onlAuthPageService.queryListHideColumn(id, str);
        return arrayList;
    }

    /* renamed from: a */
    private String m222a(OnlCgformHead onlCgformHead, Map<String, List<DictModel>> map, List<Map<String, Object>> list, String str, String str2, Object obj) {
        String[] split;
        List<DictModel> list2;
        String obj2 = obj.toString();
        if ("Y".equals(onlCgformHead.getIsTree()) && onlCgformHead.getTreeParentIdField().equals(str)) {
            return m234a(list, str, onlCgformHead.getTreeFieldname(), obj2);
        }
        ArrayList arrayList = new ArrayList();
        for (String str3 : obj2.split(CgformUtil.f233E)) {
            String str4 = "";
            for (Map<String, Object> map2 : list) {
                if (str3.equals(CgformUtil.m360a(map2, str2))) {
                    str4 = CgformUtil.m360a(map2, str);
                    if (str4 != null && (list2 = map.get(str)) != null && list2.size() > 0) {
                        for (DictModel dictModel : list2) {
                            if (dictModel.getValue().equals(str4)) {
                                str4 = dictModel.getText();
                            }
                        }
                    }
                }
            }
            if (oConvertUtils.isNotEmpty(str4)) {
                arrayList.add(str4);
            }
        }
        if (arrayList.size() > 0) {
            return String.join(CgformUtil.f233E, arrayList);
        }
        return "";
    }

    /* renamed from: a */
    private String m234a(List<Map<String, Object>> list, String str, String str2, String str3) {
        Map<String, Object> m235a = m235a(list, str3);
        if (m235a == null) {
            return str3;
        }
        String m360a = CgformUtil.m360a(m235a, str);
        if (oConvertUtils.isEmpty(m360a) || "0".equals(m360a)) {
            return "";
        }
        Map<String, Object> m235a2 = m235a(list, m360a);
        if (m235a2 == null) {
            return str3;
        }
        String m360a2 = CgformUtil.m360a(m235a2, str2);
        if (m360a2 != null) {
            return m360a2;
        }
        return str3;
    }

    /* renamed from: a */
    private Map<String, Object> m235a(List<Map<String, Object>> list, String str) {
        for (Map<String, Object> map : list) {
            String m360a = CgformUtil.m360a(map, "id");
            if (m360a != null && m360a.equals(str)) {
                return map;
            }
        }
        return null;
    }

    /* renamed from: a */
    public <T> T m253a(String str, QueryWrapper<?> queryWrapper, Class<T> cls) {
        String sqlInjectTableName = SqlInjectionUtil.getSqlInjectTableName(str);
        if (cls == JSONObject.class) {
            return (T) ((OnlCgformFieldMapper) this.baseMapper).doSelect(sqlInjectTableName, queryWrapper);
        }
        return (T) ((OnlCgformFieldMapper) this.baseMapper).doSelectList(sqlInjectTableName, queryWrapper);
    }

    /* renamed from: a */
    public <T> T m250a(String str, String str2, QueryWrapper<?> queryWrapper, Class<T> cls) {
        String str3;
        if (oConvertUtils.isNotEmpty(str2)) {
            str3 = SqlInjectionUtil.getSqlInjectField(str2);
        } else {
            str3 = "*";
        }
        queryWrapper.select(new String[]{str3});
        return (T) m253a(str, queryWrapper, cls);
    }

    /* renamed from: a */
    private int m255a(String str, JSONObject jSONObject, UpdateWrapper<?> updateWrapper) {
        String sqlInjectTableName = SqlInjectionUtil.getSqlInjectTableName(str);
        for (String str2 : jSONObject.keySet()) {
            String sqlInjectField = SqlInjectionUtil.getSqlInjectField(str2);
            updateWrapper.set(sqlInjectField, jSONObject.get(sqlInjectField));
        }
        return ((OnlCgformFieldMapper) this.baseMapper).doUpdate(sqlInjectTableName, updateWrapper);
    }

    @Override // org.jeecg.modules.online.cgform.service.IOnlCgformFieldService
    public Integer queryCountBySql(String tableName, String pidField, String metaPid) {
        QueryWrapper<?> queryWrapper = new QueryWrapper<>();
        queryWrapper.select(new String[]{"count(1) as COUNT"});
        if (oConvertUtils.isNotEmpty(pidField)) {
            queryWrapper.eq(SqlInjectionUtil.getSqlInjectField(pidField), metaPid);
        }
        JSONObject jSONObject = (JSONObject) m253a(tableName, queryWrapper, JSONObject.class);
        if (jSONObject == null) {
            return 0;
        }
        if (jSONObject.containsKey("COUNT")) {
            return jSONObject.getInteger("COUNT");
        }
        return jSONObject.getInteger("count");
    }

    /* renamed from: a */
    private Integer m254a(String str, QueryWrapper<?> queryWrapper) {
        return Integer.valueOf(((OnlCgformFieldMapper) this.baseMapper).doDelete(SqlInjectionUtil.getSqlInjectTableName(str), queryWrapper));
    }
}
